﻿using Domain.Flow;
using MediatR;
using U.B.ErrorCode;
using U.B.ReadApi.Command.Raddit.BW;
using U.B.Repistory;

namespace U.B.ReadApi.CommandHander.Raddit.BWHA
{
    public class GetImmuneCommandHander : IRequestHandler<GetImmuneCommand, ApiResult<Immune>>
    {
        public readonly IRepistory<Immune> _immuneRepository;

        public GetImmuneCommandHander(IRepistory<Immune> immuneRepository)
        {
            _immuneRepository = immuneRepository;
        }
        /// <summary>
        /// 健康信息反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<ApiResult<Immune>> Handle(GetImmuneCommand request, CancellationToken cancellationToken)
        {
           ApiResult<Immune> apiResult = new ApiResult<Immune>();
            var result = _immuneRepository.GetAll().FirstOrDefault(x => x.BatchNo == request.BatchNo);
            apiResult.Data = result;
            apiResult.code = Renum.显示成功;
            apiResult.Message=Renum.显示成功.ToString();
            return Task.FromResult(apiResult);
        }
    }
}
